import greenfoot.*;  // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)

/**
 * It's just a part of the game. The animation that will represent the girl the hero must save.
 * 
 * @author Manuel Nava
 * @version 1.0
 */
public class Tina extends Actor
{
    /**
     * The act in this class calls two methods, the one that moves the object around the world and the one that
     * changes the image of this object as it get to a determinated range of his location.
       */
    public void act() 
    {
        anima();
        move();
    }  
    
    /**
     * This method changes the image as it gets at a certain range.
       */
    public void anima()
    {
        if(getX()<450&&getX()>300)
           setImage(new GreenfootImage("tina2.png"));
        if(getX()<300)
           setImage(new GreenfootImage("tina3.png"));
    }
    
    /**
     * This method moves the actor around the world as long as the cont of the world let it happens.
       */
    public void move()
    {
        if(((CaveWorld)(getWorld())).getCont()>0)
        {
        if(Greenfoot.isKeyDown("left")&&((CaveWorld)(getWorld())).getMove()==true)
            setLocation(getX()+5,getY());
        if(Greenfoot.isKeyDown("right")&&((CaveWorld)(getWorld())).getMove()==true)
            setLocation(getX()-5,getY());
        }
    }
}
